package klimuts.periodicals.user.actions;

import java.util.Map;

import klimuts.periodicals.catalog.actions.ShowCatalog;
import klimuts.periodicals.user.Cart;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

/**
 * Prepare cart variable and show users order page.
 * If cart is <code>null</code> or not have items then user will be
 * redirected to {@link ShowCatalog} action.
 * @author Klimuts Siarhei
 */
public class ShowOrder extends ActionSupport implements SessionAware {
	private Map<String,Object> session;
	private Cart cart;
	
	public String execute() throws Exception {
		cart=(Cart)session.get("cart");
		if ((cart!=null)&&(!cart.isEmpty()))
			return "success";
		else			
			return "input";
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public Cart getCart() {
		return cart;
	}

	public void setCart(Cart cart) {
		this.cart = cart;
	}

}
